CONTENTS | INDEX | PREV | NEXT
 strtod

   NAME
    strtod  - Convert string to fp double

   SYNOPSIS
    double d = strtod(s, &tp);
    const char *s;
    char *tp;

   FUNCTION
    Converts a string to a floating point double.  Initial white space
    is skipped.  The format of the fp number in the string is then:

    {+/-/<nothing>}ddddd[.ddddd][E{+/-/<nothing>}dddd]

    Example fp strings: " +1.234E-3", "-1234", "6.5676E4", "214.2345"

   EXAMPLE

    /*
     *  compile -lm to include math library
     */

    #include <stdio.h>
    #include <string.h>

    main()
    {
        double d;
        char *tp;

        d = strtod("1.2134 3.45E2", &tp);
        printf("1.2134 = %lfn", d);    /*  1.213400    */

        d = strtod(tp, &tp);
        printf("3.45E2 = %lfn", d);    /*  345.000000  */

        return(0);
    }

   INPUTS
    char *s;    pointer to string containing fp number

    char **tp;  pointer to pointer, the pointer is modified to
            point to the end of the scanned fp number

   RESULTS
    double d;   resulting double

   SEE ALSO